package com.cloud.doc.web;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.servlet.ModelAndView;

import com.cloud.doc.model.DocFile;
import com.cloud.doc.service.DocDetailService;

@Controller
@RequestMapping("docdetail")
public class DocDetailBean {

	@Autowired
	private DocDetailService docDetailService;
	
	/**
	 * init doc detail before open detail page
	 * 
	 * @param docId
	 * @return
	 */
	@RequestMapping("/openDoc.do")
	public ModelAndView openDoc(@RequestParam("docId") String docId) {
		
		ModelAndView mv = new ModelAndView("doc/docdetail");
		
		DocFile doc = docDetailService.getDocFile(docId);
		mv.addObject("doc", doc);
		
		return mv;
	}
}
